set $mod Mod4

# set keyboard layout
#exec "setxkbmap -layout sv"

#####################[WINDOWS AND WORKSPACES]#######################
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

#set the gaps
gaps inner 0
for_window [class="mpv"] floating enable
for_window [class=".*"] border pixel 0

# for_window [instance="origin.exe"] floating enable
smart_borders on
# smart_gaps on

# kill focused window
bindsym $mod+q kill

# change focus
bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+l focus up
bindsym $mod+semicolon focus right

# Move focus
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# Move window
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

# split in horizontal orientation
bindsym $mod+h split h

# split in vertical orientation
bindsym $mod+v split v

# Toggle touchpad
bindsym $mod+t exec ~/.scripts/toggle_touchpad.sh
 
# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle

# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

# switch to workspace
bindsym $mod+1 workspace 1
bindsym $mod+2 workspace 2
bindsym $mod+3 workspace 3
bindsym $mod+4 workspace 4
bindsym $mod+5 workspace 5
bindsym $mod+6 workspace 6
bindsym $mod+7 workspace 7
bindsym $mod+8 workspace 8
bindsym $mod+9 workspace 9
bindsym $mod+0 workspace 10

# PageUp & PageDown
bindsym $mod+Prior workspace prev
bindsym $mod+Next workspace next

# Media Player Keys
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous

# Change workspace monitor 
bindsym $mod+m move workspace to output left
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace 1
bindsym $mod+Shift+2 move container to workspace 2
bindsym $mod+Shift+3 move container to workspace 3
bindsym $mod+Shift+4 move container to workspace 4
bindsym $mod+Shift+5 move container to workspace 5
bindsym $mod+Shift+6 move container to workspace 6
bindsym $mod+Shift+7 move container to workspace 7
bindsym $mod+Shift+8 move container to workspace 8
bindsym $mod+Shift+9 move container to workspace 9
bindsym $mod+Shift+0 move container to workspace 10

# resize window (you can also use the mouse for that)
bindsym MOD1+Left resize shrink width 2 px or 2 ppt
bindsym MOD1+Down resize shrink height 2 px or 2 ppt
bindsym MOD1+Up resize grow height 2 px or 2 ppt
bindsym MOD1+Right resize grow width 2 px or 2 ppt

bindsym $mod+r mode "resize"

mode "resize" {
        # These bindings trigger as soon as you enter the resize mode

        # Pressing left will shrink the window’s width.
        # Pressing right will grow the window’s width.
        # Pressing up will shrink the window’s height.
        # Pressing down will grow the window’s height.
        bindcode 44 resize shrink width 10 px or 10 ppt
        bindcode 45 resize grow height 10 px or 10 ppt
        bindcode 46 resize shrink height 10 px or 10 ppt
        bindcode 47 resize grow width 10 px or 10 ppt

        # same bindings, but for the arrow keys
        bindcode 113 resize shrink width 10 px or 10 ppt
        bindcode 116 resize grow height 10 px or 10 ppt
        bindcode 111 resize shrink height 10 px or 10 ppt
        bindcode 114 resize grow width 10 px or 10 ppt

        # back to normal: Enter or Escape or $mod+r
        bindcode 36 mode "default"
        bindcode 9 mode "default"
        bindcode $mod+27 mode "default"
}

# styling (for non-tiled windows)
font pango: FreeSans 13
 # class                 border  backgr. text    indicator
    client.focused          #444444 #444444 #444444 #444444
    client.focused_inactive #333333 #333333 #333333 #333333
    client.unfocused        #333333 #333333 #333333 #333333
    client.urgent           #333333 #333333 #333333 #333333
    client.placeholder      #333333 #333333 #333333 #333333

    new_window 1pixel
###############[KEYBINDINGS]##################
# show notification center
# bindsym $mod+n exec "kill -s USR1 $(pidof deadd-notification-center)"

# take screenshot
bindsym Print exec "mate-screenshot"
bindsym $mod+Print exec "mate-screenshot -w"

# start a terminal
bindsym $mod+Return exec "alacritty"

# open dmenu
bindsym $mod+d exec dmenu_run -b -fn nerd-fonts-hack

# start firefox
bindsym $mod+i exec "firefox"

# Sound output
bindsym XF86AudioRaiseVolume exec  pactl set-sink-volume 0 +5%
bindsym XF86AudioLowerVolume exec pactl set-sink-volume 0 -5%
bindsym XF86AudioMute exec pactl set-sink-mute 0 toggle # mute sound

#Lock Screen 
bindsym $mod+x exec betterlockscreen -l pixel -t "Stay out!"
############[OTHER STUFF]##################
# reload the configuration file
bindsym $mod+Shift+c reload

# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart

# exit i3 (logs you out of your X session)
bindsym $mod+Shift+q exec --no-startup-id \
	"i3-nagbar -t warning -m 'Do you really want to exit i3?' -b 'Shutdown' 'systemctl poweroff' -b 'Reboot' 'systemctl reboot' -b 'Logout' 'i3-msg exit'"

#####################[STARTUP]#####################
exec_always nitrogen --restore
# exec_always --no-startup-id "killall -q cbatticon"
exec_always --no-startup-id "killall -q dunst"
#exec_always --no-startup-id "~/.config/i3/update-bg"
exec_always --no-startup-id "picom --experimental-backends"
exec_always --no-startup-id "~/.config/polybar/launch.sh"
exec --no-startup-id redshift -l 39.87:32.87
exec_always  --no-startup-id "dunst"
exec --no-startup-id xfce4-power-manager
# exec --no-startup-id mailspring -b
# exec --no-startup-id firefox-developer-edition
# exec --no-startup-id nextcloud --background
# exec --no-startup-id jetbrains-toolbox --minimize
# exec --no-startup-id  /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
#exec --no-startup-id whatsapp-nativefier-dark
# exec --no-startup-id indicator-kdeconnect
# exec --no-startup-id /usr/lib/kdeconnectd
#exec --no-startup-id anamnesis --start
exec --no-startup-id xss-lock -- betterlockscreen -l -t 'stay out'
# ------------- Window Settings ----------------
for_window [class="Yad" title="yad-calendar"] floating enable
# assign [class="discord"] 9
# assign [class="TelegramDesktop"] 9
#for_window [class="whatsapp-nativefier-d52542"] move to workspace 9
# assign [class="Mailspring"] 8
#assign [class="Sublime_text"] 3
# assign [class="code-oss"] 3
# assign [class="jetbrains-idea"] 3
# assign [class="jetbrains-clion"] 3
# assign [class="Nemo"] 4
# for_window [class="Spotify"] move to workspace 10
# assign [class="youtube-music-desktop-app"] 10
# assign [class="Termite"] 1
# assign [class="firefoxdeveloperedition"] 2
# assign [class="Tor Browser"] 2
# assign [class="Chromium"] 2
# ----------------------------------------------
